gtkbutton: Drop grab_notify handler
authorCarlos Garnacho <carlosg@gnome.org>
Wed, 24 Jun 2020 12:17:15 +0000 (14:17 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Wed, 24 Jun 2020 18:35:22 +0000 (20:35 +0200)
The click gesture already has a ::cancel handler, and does almost
everything it should. Move the last bits and remove the grab_notify
handler.

gtk/gtkbutton.c

index 425bac06757eb9c8ef55d9a5740debda95c18688..8a0c084b5221791e215a2754c78f31f92f9dfc26 100644 (file)
@@ -140,8 +140,6 @@ static void gtk_button_finish_activate (GtkButton         *button,
 
 static void gtk_button_state_flags_changed (GtkWidget     *widget,
                                             GtkStateFlags  previous_state);
-static void gtk_button_grab_notify     (GtkWidget             *widget,
-                                       gboolean               was_grabbed);
 static void gtk_button_do_release      (GtkButton             *button,
                                         gboolean               emit_clicked);
 static void gtk_button_set_child_type (GtkButton *button, guint child_type);
@@ -212,7 +210,6 @@ gtk_button_class_init (GtkButtonClass *klass)
 
   widget_class->unrealize = gtk_button_unrealize;
   widget_class->state_flags_changed = gtk_button_state_flags_changed;
-  widget_class->grab_notify = gtk_button_grab_notify;
   widget_class->unmap = gtk_button_unmap;
   widget_class->compute_expand = gtk_button_compute_expand;
   widget_class->get_request_mode = gtk_button_get_request_mode;
@@ -369,6 +366,11 @@ click_gesture_cancel_cb (GtkGesture       *gesture,
                          GdkEventSequence *sequence,
                          GtkButton        *button)
 {
+  GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
+
+  if (priv->activate_timeout)
+    gtk_button_finish_activate (button, FALSE);
+
   gtk_button_do_release (button, FALSE);
 }
 
@@ -935,22 +937,6 @@ gtk_button_state_flags_changed (GtkWidget     *widget,
     gtk_button_do_release (button, FALSE);
 }
 
-static void
-gtk_button_grab_notify (GtkWidget *widget,
-                        gboolean   was_grabbed)
-{
-  GtkButton *button = GTK_BUTTON (widget);
-  GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
-
-  GTK_WIDGET_CLASS (gtk_button_parent_class)->grab_notify (widget, was_grabbed);
-
-  if (was_grabbed && priv->activate_timeout)
-    gtk_button_finish_activate (button, FALSE);
-
-  if (!was_grabbed)
-    gtk_button_do_release (button, FALSE);
-}
-
 /**
  * gtk_button_set_icon_name:
  * @button: A #GtkButton